<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/22 0022
 * Time: 14:39
 */

namespace app\common\model\common;

use app\common\model\TimeModel;

class Collect extends TimeModel
{
    protected $deleteTime = 'delete_time';
    /**
     * 关联标签
     */
    public function stores(){

        return $this->belongsTo('app\common\model\mall\Store','account_id','id');

    }
    //与线下课程多对多关联
    public function account()
    {
        return $this->belongsTo('app\common\model\media\Account','account_id','id');
    }
    //线上课程多对多
    public function net()
    {
        return $this->belongsTo('app\common\model\media\Account','account_id','id');
    }
    public static function onAfterInsert($data){

        //$self = new static();
        $article = self::withoutGlobalScope()->find($data->id);

        $article->withoutGlobalScope()->where('id',$data->id)->save(['app_id'=>self::get_appId()]);

    }
    /**
     * 定义全局的查询范围
     * @param \think\db\Query $query
     */
    public function scopeApp_id($query)
    {
        return true;

    }
}